const mongoose = require('mongoose');
const Schema = mongoose.Schema;

// 实例化数据模板
const ProfilesSchema = new Schema({
  user: {
    type: String,
    ref: 'users',
    require: true
  },
  handle: {
    type: String,
    require: true,
    max: 40
  },
  company: {
    type: String,
  },
  avatar: {
    type: String,
  },
  website: {
    type: String,
  },
  location: {
    type: String,

  },
  status: {
    type: String,
    require: true,
  },
  skills: {
    type: [String],
    require: true,
  },
  bio: {
    type: String,

  },
  githubusername: {
    type: String,
  },
  experience: [{
    title: {
      type: String,
      require: true,
    },
    company: {
      type: String,
      require: true,
    },
    location: {
      type: String,
    },
    from: {
      type: String,
      require: true,

    },
    to: {
      type: String,
    },
    description: {
      type: String,
    }
  }],
  education: [{
    school: {
      type: String,
      require: true,
    },
    degree: {
      type: String,
    },
    fieldofstudy: {
      type: String,
    },
    from: {
      type: String,
      require: true,

    },
    to: {
      type: String,
    },
    description: {
      type: String,
    }
  }],
  social: {
    wechat: {
      type: String,
    },
    QQ: {
      type: String,
    },
    tengxunkt: {
      type: String,
    },
    wangyikt: {
      type: String,
    },
  },
  date: {
    type: Date,
    default: Date.now
  }
})


module.exports = User = mongoose.model("profile", ProfilesSchema)